package com.smugmugsoftware.airconcalc.advanced;

import android.os.Parcel;
import android.os.Parcelable;

public class CeilingFloor extends RoomComponent {
	
	private boolean[] isCathedral;

	public CeilingFloor(long id) {
		super(id);
		isCathedral = new boolean[] { false, false };
	}
	
	public String getTypeString() {
		int checkNumber = Integer.valueOf(this.constructionNumber.substring(0, 2));
		
		if (checkNumber >= 16 && checkNumber <= 18) {
			return "Ceiling";
		} else if (checkNumber >= 19 && checkNumber <= 23) {
			return "Floor";
		} else {
			return "";
		}
	}

	public boolean isACeiling() {
		int checkNumber = Integer.valueOf(this.constructionNumber.substring(0, 2));
		
		if (checkNumber >= 16 && checkNumber <= 18) {
			return true;
		} else if (checkNumber >= 19 && checkNumber <= 23) {
			return false;
		} else {
			return false;
		}
	}

	public boolean isCathedral() {
		return isCathedral[0];
	}
	public boolean isVaulted() {
		return isCathedral[1];
	}
	
	public String getCeilingTypeString() {
		if (isCathedral()) {
			return "Cathedral";
		} else if (isVaulted()) {
			return "Vaulted";
		}
		
		return "";
	}
	
	@Override
	public void setArea(double area) {
		super.setArea(area);
		isCathedral[0] = false;
		isCathedral[1] = false;
	}
	
	public void setArea(double area, boolean[] isCathedral) {
		super.setArea(area);
		this.isCathedral[0] = isCathedral[0];
		this.isCathedral[1] = isCathedral[1];
	}
	
	public void writeToParcel(Parcel dest, int flags) {
		super.writeToParcel(dest, flags);
		dest.writeBooleanArray(isCathedral);
	}

	public static final Parcelable.Creator<CeilingFloor> CREATOR = new Parcelable.Creator<CeilingFloor>() {
		public CeilingFloor createFromParcel(Parcel in) {
			return new CeilingFloor(in);
		}

		public CeilingFloor[] newArray(int size) {
			return new CeilingFloor[size];
		}
	};

	public CeilingFloor(Parcel p) {
		super(p);
		isCathedral = new boolean[2];
		p.readBooleanArray(isCathedral);
	}
}